<template>
  <div class="snowfall-container">
    <div
      v-for="(snowflake, index) in snowflakes"
      :key="index"
      class="snowflake"
      :style="snowflake.style"
    ></div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      snowflakes: []
    };
  },
  mounted () {

  },
  methods: {
    showFn () {
      this.createSnowflakes();
      setInterval(this.createSnowflakes, 3000);
    },
    createSnowflakes () {
      const numSnowflakes = Math.floor(Math.random() * 10) + 1;
      for (let i = 0; i < numSnowflakes; i++) {
        const left = Math.random() * 100 + 'vw';
        const animationDuration = (Math.random() * 5 + 5) + 's'; // Random duration between 5s to 10s
        this.snowflakes.push({
          style: {
            left,
            animationDuration
          }
        });
      }
    }
  }
};
</script>

<style scoped>
.snowfall-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.snowflake {
  position: absolute;
  top: -10px;
  width: 5px;
  height: 5px;
  background-color: #000;
  border-radius: 50%;
  opacity: 0.7;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    transform: translateY(110vh);
  }
}
</style>
